﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="cbsgl.aspx.cs" Inherits="Catering.Catering_Page.richang.cbsgl" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=7" />
    <title>菜品管理</title>
    <link rel="stylesheet" type="text/css" href="../../Style/head_2.css" />
    <link rel="stylesheet" type="text/css" href="../../Style/center.css" />
    <link rel="stylesheet" type="text/css" href="../../Style/zhezhao_2.css" />
    <script src="../../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script src="../../Style/zhezhao.js" type="text/javascript"></script>
    <script src="../../Style/xxk.js" type="text/javascript"></script>
    <script language="javascript" type="text/javascript" src="../../Scripts/My97DatePicker/WdatePicker.js"></script>
    <style type="text/css">
        .Create_Recipe
        {
            margin-top: 0;
        }
        .Create_Recipe
        {
            border: 1px solid #159aec;
            border-top: none;
            width: 998px;
        }
        .soso_lt
        {
            padding: 5px 0;
        }
        .soso_lt a
        {
            margin-left: 3px;
        }
    </style>
    
    <script type="text/javascript">
        //删除承包商
        function Tr_Del(cid) {
            if (!confirm("确认删除？")) {
                return;
            }

            $.ajax({
                type: "Post",
                url: "cbsgl.aspx/Del_Contractor",
                data: "{'strid':'" + cid + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    if (data.d == "OK") {
                        alert("删除成功！");
                        history.go(0);
                    }
                }
            });
        }

        //显示弹出层
        function Tr_ShowDiv(n,cid) {
            if (n == "add") {
                $("#btn_Add").show();
                $("#btn_Edit").hide();
                $("#gzltj").hide();
                $("#div_main input[type='text']").val("");
                $("#div_main textarea").val("");
                divshow("div_main", "div_bg");
            }
            else {
                
                $("#btn_Add").hide();
                $("#btn_Edit").show();
                $("#Hidcid").val(cid);
                $("#gzltj").show();
                var date = $("#Txt_data").val();
                cbsgl.Get_Contractor(cid,date,Loadcbs);
            }
        }

        function Loadcbs(data) {
            if (data.value == null) {
                return;
            }
            var ds = data.value;
            if (ds == null || typeof (ds) != "object") {
                return;
            }

            $("#txt_cbsname").val(ds.Rows[0].CName);  //承包商名称
            $("#txt_lxr").val(ds.Rows[0].LinkId);          //联系人
            $("#txt_tel").val(ds.Rows[0].Tel);          //联系电话
            $("#txt_dz").val(ds.Rows[0].Add);            //地址
            $("#Drop_cbszt").val(ds.Rows[0].State);            //状态
            $("#txt_content").val(ds.Rows[0].ContentDesc);            //评价或说明
            $("#txt_sm").val(ds.Rows[0].Description);            //评价或说明
            divshow("div_main", "div_bg");
        }

        //添加承包商
        function Tr_Add() {
            var cbsname = $("#txt_cbsname").val();  //承包商名称
            var lxr = $("#txt_lxr").val();          //联系人
            var tel = $("#txt_tel").val();          //联系电话
            var dz = $("#txt_dz").val();            //地址
            var zt = $("#Drop_cbszt").val();            //状态
            var sm = $("#txt_sm").val();            //评价或说明

            $.ajax({
                type: "Post",
                url: "cbsgl.aspx/Add_Contractor",
                data: "{'CName':'" + cbsname + "','LinkId':'" + lxr + "','Tel':'" + tel + "','Add':'" + dz + "','State':'" + zt + "','Description':'" + sm + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    if (data.d == "OK") {
                        alert("保存成功！");
                        history.go(0);
                    }
                }
            });
        }

        //修改承包商
        function Tr_Edit() {
            var cid = $("#Hidcid").val();           //修改的ID
            var cbsname = $("#txt_cbsname").val();  //承包商名称
            var lxr = $("#txt_lxr").val();          //联系人
            var tel = $("#txt_tel").val();          //联系电话
            var dz = $("#txt_dz").val();            //地址
            var zt = $("#Drop_cbszt").val();            //状态
            var sm = $("#txt_sm").val();            //评价或说明

            $.ajax({
                type: "Post",
                url: "cbsgl.aspx/Edit_Contractor",
                data: "{'cid':'" + cid + "','CName':'" + cbsname + "','LinkId':'" + lxr + "','Tel':'" + tel + "','Add':'" + dz + "','State':'" + zt + "','Description':'" + sm + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    if (data.d == "OK") {
                        alert("保存成功！");
                        history.go(0);
                    }
                }
            });
        }

        //显示承包商信息
        function Tr_EditInfo(cid) {
            $("#Hidcid").val(cid);
            cbsgl.Get_ContractorInfo(cid, LoadMainInfo);
        }

        function LoadMainInfo(data) {
            if (data.value == null) {
                return;
            }
            var ds = data.value;
            if (ds != null && ds.Rows[0]!=undefined && typeof (ds) == "object") {
                $("#txt_info_name").val(ds.Rows[0].CName);  //姓名
                $("#txt_info_zyq").val(ds.Rows[0].GroupID);   //负责作业区
                $("#txt_info_kh").val(ds.Rows[0].CardNo);    //跟踪卡号
                $("#txt_info_zjmc").val(ds.Rows[0].JobCard);  //工作证件名称
                $("#txt_info_zjqj").val(ds.Rows[0].Effective);  //工作证件有效区间
                $("#txt_info_zjqj_end").val(ds.Rows[0].EffectiveEnd);  //工作证件有效区间
                $("#txt_info_tel").val(ds.Rows[0].Tel);       //电话
                $("#txt_info_yxqj").val(ds.Rows[0].EffectiveArea);  //有效区间
            }
            divshow("div_main_info", "div_bg");
            
        }


        //提交承包商详细信息
        function Tr_Info_Add() {
            var CID = $("#Hidcid").val();           //承包商ID
            var CName = $("#txt_info_name").val();  //姓名
            var GroupID = $("#txt_info_zyq").val();   //负责作业区
            var CardNo = $("#txt_info_kh").val();    //跟踪卡号
            var JobCard = $("#txt_info_zjmc").val();  //工作证件名称
            var Effective = $("#txt_info_zjqj").val();  //工作证件有效区间
            var EffectiveEnd = $("#txt_info_zjqj_end").val();  //工作证件有效区间
            var Tel = $("#txt_info_tel").val();             //电话
            var EffectiveArea = $("#txt_info_yxqj").val();  //有效区间

            //string CID, string CName, string GroupID, string CardNo, string JobCard, string Effective, string Tel, string EffectiveArea
            $.ajax({
                type: "Post",
                url: "cbsgl.aspx/Edit_ContractorInfo",
                data: "{'CID':'" + CID + "','CName':'" + CName + "','GroupID':'" + GroupID + "','CardNo':'" + CardNo + "','JobCard':'" + JobCard + "','Effective':'" + Effective + "','Tel':'" + Tel + "','EffectiveArea':'" + EffectiveArea + "','EffectiveEnd':'" + EffectiveEnd + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    if (data.d == "OK") {
                        alert("保存成功！");
                        history.go(0);
                    }
                }
            });

        }

    </script>
    
</head>
<body>
    <form runat="server" id="from1">
    <asp:HiddenField runat="server" ID="Hidcid" />
    <div class="Center_Content" id="div_search" style="display: block">
        <div class="div_0207 left_width500" style="height:34px; width:998px;">
            <table  align="left" style="height:34px;" border="0" width="100%" cellspacing="0" cellpadding="0" class="ckgl_table ">
                <tr>
                    <td width="75" align="right">承包商名称：</td>
                    <td width="150">
                        <asp:TextBox runat="server" ID="Txt_Cname" CssClass="input_bg" Width="140"></asp:TextBox>
                    </td>
                    <td width="75" align="right">日期：</td>
                    <td width="150">
                        <asp:TextBox ID="Txt_data" runat="server" CssClass="input_bg" Width="100" 
                            ontextchanged="Txt_data_TextChanged" AutoPostBack="True"></asp:TextBox>
                    </td>
                    <td width="100">
                        <asp:Button runat="server" ID="btn_Search" CssClass="input_btn_a" Text="查询" 
                            onclick="btn_Search_Click" />
                    </td>
                    <td>&nbsp;</td>
                    <td width="100" align="right">
                        <input id="but_Nnull_Row" type="button" onclick="Tr_ShowDiv('add','-1')" value="新增" class="input_btn_a" />
                    </td>
                    <td width="100" align="right">
                        <asp:Button ID="but_Excel" Text="导出Excel" runat="server" onclick="but_Excel_Click" CssClass="input_btn_a"/>
                    </td>
                    <td width="10">&nbsp;</td>
                </tr>
            </table>
        </div>
    </div>
    <div class="Center_Content" id="div2_1" style="display: block">
            <table width="100%" border="0" cellspacing="0" cellpadding="0" class="swxx_table">
                <thead>
                    <tr>
                        <td style="width: 30px">
                            序号
                        </td>
                        <td>
                            承包商名称
                        </td>
                        <td>
                            联系人
                        </td>
                        <td>
                            联系电话
                        </td>
                        <td>
                            地址
                        </td>
                        <td>
                            状态
                        </td>
                        <td>
                            工作量统计
                        </td>
                        <td>
                            评价或说明
                        </td>
                        <td>
                            编辑
                        </td>
                        <td>
                            详细
                        </td>
                        <td>
                            删除
                        </td>
                    </tr>
                </thead>
                <tbody id="chengbaoshang">
                <asp:Repeater ID="Rep_cbs" runat="server">
                    <ItemTemplate>
                        <tr>
                            <td align="center"><%#Eval("id")%></td>
                            <td align="center"><%#Eval("CName")%></td>
                            <td align="center"><%#Eval("LinkId")%></td>
                            <td align="center"><%#Eval("Tel")%></td>
                            <td align="center"><%#Eval("Add")%></td>
                            <td align="center"><%#this.GetState(Eval("id").ToString(),this.Txt_data.Text.ToString())%>&nbsp;</td>
                            <td><%#this.GetContent(Eval("id").ToString(), this.Txt_data.Text.ToString())%>&nbsp;</td>
                            <td align="center"><%#Eval("Description")%>&nbsp;</td>
                            <td align="center"><a href="javascript:void(0);" onclick="Tr_ShowDiv('Edit','<%#Eval("id")%>')"><img src="../../../Images/file.gif" /></a></td>
                            <td align="center"><a href="cbsglInfo.aspx?uid=<%#Eval("id")%>" ><img src="../../../Images/sz03.png" /></a></td>
                            <td align="center"><a href="javascript:void(0);" onclick="Tr_Del('<%#Eval("id")%>')"><img src="../../../Images/trash.gif" /></a></td>
                        </tr>
                    </ItemTemplate>
                </asp:Repeater>
                </tbody>
            </table>
    </div>
    <div class="footer">
        <strong>中海油能源发展配餐服务公司渤海自营油田作业公司&nbsp;&nbsp;版权所有@CopyRight 2012</strong><span>技术支持：北京天择嘉业科技有限公司</span>
    </div>
    <!--=================================================================-->
     <!--遮罩层-->
    <div id="div_bg" class="bg">
        
    </div>
    <!--弹出层-->
    <div id="div_main" class="center_div_800" style="padding:10px 0px; margin-top:-130px; width:700px;">
        <table border="0" align="center">
            <tr>
                <td width="90" align="right">承包商：</td>
                <td colspan="3"><input type="text" id="txt_cbsname" style="width:140px;" class="input_bg" /></td>
            </tr>
            <tr>
                <td align="right">联系人：</td>
                <td width="140"><input type="text" id="txt_lxr" style="width:140px;" class="input_bg" /></td>
                <td width="75" align="right">联系电话：</td>
                <td width="140"><input type="text" id="txt_tel" style="width:140px;" class="input_bg" /></td>
            </tr>
            <tr>
                <td width="90" align="right">地　址：</td>
                <td colspan="3"><input type="text" id="txt_dz" class="input_bg" style="width:375px;"/></td>
                <td width="75" align="right"><%--状　　态：--%></td>
                <td>
                    <asp:DropDownList Visible="false" ID="Drop_cbszt" runat="server" CssClass="select_input_bg" Width="144">
                        <asp:ListItem Value="作业中" Text="作业中" Selected="True"></asp:ListItem>
                        <asp:ListItem Value="未作业" Text="未作业" ></asp:ListItem>
                    </asp:DropDownList>
                </td>
            </tr>
            <tr id="gzltj">
                <td width="90" align="right">工作量统计：</td>
                <td colspan="3">
                    <asp:TextBox ID="txt_content" runat="server" ReadOnly="true" CssClass="input_bg" TextMode="MultiLine" style="width:506px; height:46px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td width="90" align="right">说　明：</td>
                <td colspan="3">
                    <asp:TextBox ID="txt_sm" runat="server" CssClass="input_bg" TextMode="MultiLine" style="width:506px; height:46px"></asp:TextBox>
                </td>
            </tr>            
        </table>
        <table width="100%">
            <tr>
                <td align="right">
                    <input type="button" id="btn_Add" value="提交" class="input_btn_a" onclick="Tr_Add()"/>
                    <input type="button" id="btn_Edit" value="提交" class="input_btn_a" onclick="Tr_Edit()"/>
                </td>
                <td align="left">
                    <input type="button" id="Button2" value="关闭" class="input_btn_a" onclick="divhidel('div_main', 'div_bg');"/>
                </td>
            </tr>
        </table>
    </div>

    <!--承包商详细-->
    <div id="div_main_info" class="center_div_800" style="padding:10px 0px; margin-top:-130px; width:750px;">
        <table width="100%">
            <tr>
                <td>姓名:</td><td><input type="text" id="txt_info_name" class="input_bg" /></td>
                <td>负责作业区:</td>
                <td>
                    <asp:DropDownList runat="server" ID="txt_info_zyq"></asp:DropDownList>
                </td>
                <td>跟踪卡号:</td><td><input type="text" id="txt_info_kh" class="input_bg" /></td>
            </tr>
            <tr>
                <td>工作证件名称:</td><td><input type="text" id="txt_info_zjmc" class="input_bg" /></td>
                <td>电话:</td><td colspan="3"><input type="text" id="txt_info_tel" class="input_bg"/></td>
            </tr>
            <tr>
                <td>工作证件有效区间:</td>
                <td colspan="5">
                    <input type="text" id="txt_info_zjqj" class="input_bg" onfocus="calendar();" />
                    至
                    <input type="text" id="txt_info_zjqj_end" class="input_bg" onfocus="calendar();" />
                </td>
            </tr>
            <tr>
                <td>有效人员:</td>
                <td colspan="5">
                    <asp:TextBox ID="txt_info_yxqj" runat="server" CssClass="input_bg" TextMode="MultiLine" style="width:380px; height:40px"></asp:TextBox>
                </td>
            </tr>
        </table>
        <table width="100%">
            <tr>
                <td align="right">
                    <input type="button" id="Button1" value="提交" class="input_btn_a" onclick="Tr_Info_Add()"/>
                </td>
                <td align="left">
                    <input type="button" id="Button3" value="关闭" class="input_btn_a" onclick="divhidel('div_main_info', 'div_bg');"/>
                </td>
            </tr>
        </table>
    </div>

    </form>
</body>
</html>
